package com.qinglian.controller;

import com.qinglian.entity.User;
import com.qinglian.service.IUserService;
import com.qinglian.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author augn
 * @since 2023-04-14
 */
@RestController
@CrossOrigin
@RequestMapping("/user")
public class UserController {

    @Autowired
    private IUserService service;
    // 用户登录
    @GetMapping("/register")
    public Result<?> register(@RequestParam String account,@RequestParam String password,@RequestParam Integer code) {
        return service.register(account,password,code);
    }

    // 用户登录
    @GetMapping("/login")
    public Result<?> login(@RequestParam String account,@RequestParam String password) {
        return service.login(account,password);
    }

    // 更新用户信息
    @PostMapping("/update")
    public Result<?> update(@RequestBody User user){
        System.out.println(user);
        return service.update(user);
    }

    // 用户登录
    @GetMapping("/getUserByAccount")
    public Result<?> getUserByAccount(@RequestParam Integer account) {
        return service.getUserByAccount(account);
    }
}
